#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Moty
# @Time     : 2024/10/18 22:39
# @File     : kc16_31.py
# @Project  : CSPT
def parse_31_Charging_Station_Applies_Start_Charging(body):
    # 解析0x31 充电桩主动申请启动充电
    data = {
        "桩编号": f"{body[0:14]}({body[0:14]})",
        "枪号": f"{int(body[14:16], 16)}枪({body[14:16]})",
        "启动方式": f"{start_type(body[16:18])}({body[16:18]})",
        "是否需要密码": f"{need_passwd(body[18:20])}({body[18:20]})",
        "账号或者物理卡号": f"{body[28:36]}({body[20:36]})",
        "输入密码": f"{body[36:72]}({body[36:72]})",
        "VIN 码": f"{body[72:106]}({body[72:106]})",
    }
    formatted_data = ""
    for key, value in data.items():
        formatted_data += f"{key}: {value}\n"
    return formatted_data


def start_type(result):
    return "刷卡启动" if result == "01" else "账号启动" if result == "02" else "VIN 码启动" if result == "03" else "未知"


def need_passwd(result):
    return "不需要" if result == "00" else "需要" if result == "01" else "未知"


__all__ = ['parse_31_Charging_Station_Applies_Start_Charging']